package scala.test_traits.multi_parameter

/**
 * @author 黄海峰 2021/4/17 23:28
 * */
object DeanTest {
  def main(args: Array[String]): Unit = {
    val numberList = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    val result = numberList.foldLeft(0)((m, n) => m + n)

    println(result)

    val numbers = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    val numberFunc = numbers.foldLeft(List[Int]()) _

    val squares = numberFunc((xs, x) => xs :+ x * x)
    println(squares)
    // List(1, 4, 9, 16, 25, 36, 49, 64, 81, 100)

    val cubes = numberFunc((xs, x) => xs :+ x * x * x)
    println(cubes)
    // List(1, 8, 27, 64, 125, 216, 343, 512, 729, 1000)
  }
}

/**
 * Methods may have multiple parameter lists.
 */